package com.easygem.business.service.imp;

import com.easygem.business.mapper.BgCircuitMapper;
import com.easygem.business.service.BgCircuitService;
import com.easygem.business.service.base.AbstractServiceImpl;
import com.easygem.common.model.business.Circuit;
import com.easygem.common.model.business.SysNotice;
import com.easygem.common.vo.system.PageVO;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 何维佳
 * @version 1.0
 * @className CircuitServiceImpl
 * @Description TODO
 * @date 2025/2/27 18:21
 */
@Service
public class BgCircuitServiceImpl extends AbstractServiceImpl<BgCircuitMapper, Circuit,Integer> implements BgCircuitService {
    @Autowired
    private BgCircuitMapper circuitMapper;
    /**
     * 得到所有线路类型
     *
     * @return 线路类型集合
     */
    @Override
    public List<Circuit> getCircuitAll() {
        return circuitMapper.getCircuitAll();
    }
    /**
     * 分页查询线路类型
     * @param pageNum 当前页
     * @param pageSize 每页显示条数
     * @return 线路类型集合
     */
    @Override
    public PageVO<Circuit> getCircuitPage(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<Circuit> circuitList = circuitMapper.getCircuitAll();
        System.out.println("!!!!!!!!!!!!!!"+circuitList);
        PageInfo<Circuit> info=new PageInfo<>(circuitList);
        return new PageVO<>(info.getTotal(),circuitList);
    }

    /**
     * 根据id查询线路类型
     *
     * @param id 线路类型id
     * @return 线路类型对象
     */
    @Override
    public Circuit getCircuitById(Long id) {
        return circuitMapper.getCircuitById(id);
    }

    /**
     * 修改线路类型
     *
     * @param circuit 线路类型对象
     * @return
     */
    @Override
    public int updateCircuit(Circuit circuit) {
        return circuitMapper.updateByPrimaryKeySelective(circuit);
    }

    /**
     * 添加线路类型
     *
     * @param circuit 线路类型对象
     * @return
     */
    @Override
    public int addCircuit(Circuit circuit) {
        return circuitMapper.insertSelective(circuit);
    }
}
